﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class UserControls_advsearch : System.Web.UI.UserControl
{
    private DataSet dsSerachResult = new DataSet();
    public DataSet SearchResult
    {
        get { return dsSerachResult; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            drpFunctionalArea.DataSource = JobSiteStarterKit.BOL.FunctionalArea.GetAllFunctionalArea();
            drpFunctionalArea.DataTextField = "SubCategoryName";
            drpFunctionalArea.DataValueField = "SubCategoryId";
            drpFunctionalArea.DataBind();
            
            drpExp.DataSource = JobSiteStarterKit.BOL.ExperienceLevel.GetExperienceLevels();
            drpExp.DataTextField = "ExperienceLevelName";
            drpExp.DataValueField = "ExperienceLevelID";
            drpExp.DataBind();
        }

    }

    
    protected void btnSearch_Click(object sender, ImageClickEventArgs e)
    {
        JobSiteStarterKit.BOL.JobSearch job = new JobSiteStarterKit.BOL.JobSearch();
        string Keyword, Location, FunctionalArea;
        Keyword = (txtKeywords.Text.Trim() != "") ? txtKeywords.Text.Trim() : null;
        Location = (txtLocation.Text.Trim() != "") ? txtLocation.Text.Trim() : null;
        FunctionalArea = (drpFunctionalArea.SelectedValue != "-1") ? drpFunctionalArea.SelectedItem.Text : null;
        string[] parameters = new string[] { Keyword, Location, FunctionalArea };

        dsSerachResult = job.SearchBy(JobSiteStarterKit.ENUM.JobSearchBy.AdvanceSearch, null, parameters);
        //MasterPage master = this.Page.Master;
        
        //Control ctrl = this.Parent.FindControl("jobsearch1");
        //if (ctrl != null)
        //{
        //   // UserControls_jobsearch
        //    UserControls_jobsearch search = (UserControls_jobsearch)ctrl;
           
        //    if(search.FindControl("grdProject") != null)
        //    {
        //        GridView grd =(GridView) search.FindControl("grdProject");
        //        grd.DataSource = dsSerachResult;
        //        grd.DataBind();
        //    }
        //}
    }

}
